package fresponse

import "github.com/gin-gonic/gin"

type mError interface {
	response
}

type e struct {
	msg    string
	code   int
	option *Option
}

func (e *e) Assemble(ctx *gin.Context) {
	ctx.JSON(e.option.HttpCode, gin.H{
		"code": e.code,
		"msg":  e.msg,
	})
}

func fail(code int, msg string) mError {
	return &e{msg: msg, code: code, option: option()}
}
